package com.woniu.cinema.controller;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.woniu.common.annotation.Log;
import com.woniu.common.core.controller.BaseController;
import com.woniu.common.core.domain.AjaxResult;
import com.woniu.common.enums.BusinessType;
import com.woniu.cinema.domain.MovieImage;
import com.woniu.cinema.service.MovieImageService;
import com.woniu.common.utils.poi.ExcelUtil;
import com.woniu.common.core.page.TableDataInfo;

/**
 * 电影图片Controller
 *
 * @author yy
 * @date 2023-09-27
 */
@RestController
@RequestMapping("/cinema/movieimage")
public class MovieImageController extends BaseController
{
    @Autowired
    private MovieImageService movieImageService;

    /**
     * 查询电影图片列表
     */
    @GetMapping("/list")
    public TableDataInfo list(MovieImage movieImage)
    {
        startPage();
        List<MovieImage> list = movieImageService.selectMovieImageList(movieImage);
        return getDataTable(list);
    }

    @GetMapping("web/list")
    public TableDataInfo weblist(MovieImage movieImage)
    {
        startPage();
        List<MovieImage> list = movieImageService.selectMovieImageList(movieImage);
        return getDataTable(list);
    }

    /**
     * 导出电影图片列表
     */
    @Log(title = "电影图片", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MovieImage movieImage)
    {
        List<MovieImage> list = movieImageService.selectMovieImageList(movieImage);
        ExcelUtil<MovieImage> util = new ExcelUtil<MovieImage>(MovieImage.class);
        return util.exportExcel(list, "movieimage");
    }

    /**
     * 获取电影图片详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(movieImageService.selectMovieImageById(id));
    }

    /**
     * 新增电影图片
     */
    @Log(title = "电影图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MovieImage movieImage)
    {
        return toAjax(movieImageService.insertMovieImage(movieImage));
    }

    /**
     * 修改电影图片
     */
    @Log(title = "电影图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MovieImage movieImage)
    {
        return toAjax(movieImageService.updateMovieImage(movieImage));
    }

    /**
     * 删除电影图片
     */
    @Log(title = "电影图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(movieImageService.deleteMovieImageByIds(ids));
    }
}
